package orthoplanner.com.google.code.ui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import orthoplanner.com.google.code.eventhandlers.ContrastResetHandler;
import orthoplanner.com.google.code.eventhandlers.ImageContrastSliderHandler;


public class ContrastPanel extends JPanel {
	private static final long serialVersionUID = 2941981669032095605L;
	private JButton bReset;
	private JSlider slValue;

	public ContrastPanel(ImageViewer imgViewer) {
		setFont( new Font("SansSerif", Font.BOLD, 12));
		setPreferredSize(new Dimension(200, 80));
		bReset = new JButton("Reset");
		bReset.setFont( new Font("SansSerif", Font.BOLD, 12));
		slValue = new JSlider(SwingConstants.HORIZONTAL, 0, 300, 100);
		
		bReset.addMouseListener(new ContrastResetHandler(slValue));
		slValue.addChangeListener(new ImageContrastSliderHandler(imgViewer));
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.anchor = GridBagConstraints.LAST_LINE_END;
		add(bReset, gbc);
		gbc.gridy = 1;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		add(slValue, gbc);
		setBorder(new TitledBorder("Contrast"));
		//TODO need to implement contrast correctly
		setEnabled(false);
	}

	public JButton getbContrastReset() {
		return bReset;
	}

	public JSlider getContrastRotation() {
		return slValue;
	}

}
